# -*- coding: utf-8 -*-
'''
    :file: test.py
    :author: -Farmer
    :url: https://blog.farmer233.top
    :date: 2021/02/11 01:48:17
'''
# from flask import Flask
from flask.blueprints import Blueprint
from flask.globals import request
from flask_restful import Api, Resource
from flask import current_app

test_bp = Blueprint("test", __name__)

api = Api(test_bp)

class HelloApi(Resource):
    def get(self):
        print("Hello api")
        return {"Hello": "farmer"}

class TestApi(Resource):
    def get(self):
        current_app.logger.info("testApi-getMethod-log test.")
        return {"api-get": "get-api"}
    
    def post(self):
        return {"api-post": "post-api"}

class FormTest(Resource):
    def post(self):
        form = request.form
        return form

from app.ddns import DDNSConfig

class DnsTest(Resource):
    def post(self):
        data = request.get_json()
        state = DDNSConfig.write_db(data)
        return state
        domain_name = request.form.get('domain_name')
        accessKeyId = request.form.get('accessKeyId')
        accessSecret = request.form.get('accessSecret')

api.add_resource(HelloApi, "/hello")
api.add_resource(TestApi, "/test")
api.add_resource(FormTest, '/form')
api.add_resource(DnsTest, '/dnsTest')